import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.logging.Logger;
//import java.util.logging.Logger;

public class KeyboardListener extends KeyAdapter {

    public void keyPressed(KeyEvent e) {
        switch (e.getKeyCode()) {
            case 39:    // -> Right
                //if it's not the opposite direction
                Logger.getGlobal().info("press right!");

                if (ThreadsController.directionSnake != 2)
                    ThreadsController.directionSnake = 1;
                break;
            case 38:    // -> Top
                Logger.getGlobal().info("press top!");

                if (ThreadsController.directionSnake != 4)
                    ThreadsController.directionSnake = 3;
                break;

            case 37:    // -> Left
                Logger.getGlobal().info("press left!");

                if (ThreadsController.directionSnake != 1)
                    ThreadsController.directionSnake = 2;
                break;

            case 40:    // -> Bottom
                Logger.getGlobal().info("press down!");
                if (ThreadsController.directionSnake != 3)
                    ThreadsController.directionSnake = 4;
                break;

            default:
                break;
        }
    }

}
